package com.leapp.sk.viewdelegate.im

import android.content.Context
import android.content.Intent
import android.widget.ListView
import com.example.mvp.delegate.BaseAppDelegate
import com.leapp.sk.R
import com.example.mvp.bean.ClassMemberInfoEntity
import com.example.mvp.bean.GroupMemberEntity
import com.leapp.sk.ui.activity.classs.HeadmasterDetialActivity
import com.leapp.sk.ui.adapter.ReadmeadStateAdapter
import com.example.util.finallist.THEACHER_DATA

/**
 * 消息未读视图托管
 * @author  chaohaipeng  on 2018/7/26.
 */
class MessageUnreadDelegate: BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.fragment_message_unread
    }

    /**
     * 初始化适配器
     */
    fun initAdapter(context: Context, mlist: List<GroupMemberEntity>){
        val lv_fmur_list = getView<ListView>(R.id.lv_fmur_list)
        val readmeadStateAdapter = ReadmeadStateAdapter(getActivity(), mlist)
        lv_fmur_list.adapter=readmeadStateAdapter
        lv_fmur_list.setOnItemClickListener{adapterView, view, i, l ->
            val get = mlist.get(i)
            val phone = get.phone
            val id = get.id
            val classMemberInfoEntity = ClassMemberInfoEntity()
            classMemberInfoEntity.personnelType=get.personnelType
            classMemberInfoEntity.phone=phone!!
            classMemberInfoEntity.id= id!!
            classMemberInfoEntity.avatar=get.avatar!!
            classMemberInfoEntity.nickName=get.nickName!!
            classMemberInfoEntity.introduction=get.introduction!!
            val intent= Intent(context, HeadmasterDetialActivity::class.java)
            intent.putExtra(THEACHER_DATA,classMemberInfoEntity)
            context.startActivity(intent)
        }
    }


}